package io.renren.modules.sys.service.impl;


import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import io.renren.common.utils.PageUtils;
import io.renren.modules.sys.entity.AppointmentEntity;
import io.renren.modules.sys.entity.AppointmentTalentsEntity;
import io.renren.modules.sys.service.AppointmentService;
import io.renren.modules.sys.service.AppointmentTalentsService;


@Component
public class CrmSalesTask {

	@Autowired
	private AppointmentService appointmentService;
	
	@Autowired
	private AppointmentTalentsService appointmentTalentsService;

	private static final Logger logger = LoggerFactory.getLogger(CrmSalesTask.class);

	// 每5miao执行一次
	@Transactional
	@Scheduled(cron = "0 0/5 0 * * ?")
	public void performanceSyncTask() {
		System.err.println(1111111);
		Map<String, Object> params=new HashMap<>();
		params.put("date", new Date());
		PageUtils pageUtils=appointmentService.queryPage(params);
		for (Object appointmentEntity : pageUtils.getList()) {
			AppointmentEntity appointmentEntity2=(AppointmentEntity) appointmentEntity;
			appointmentService.deleteById(appointmentEntity2.getId());
		}
		
		PageUtils pageUtils2=appointmentTalentsService.queryPage(params);
		for (Object appointmentEntity : pageUtils2.getList()) {
			AppointmentTalentsEntity appointmentEntity2=(AppointmentTalentsEntity) appointmentEntity;
			appointmentTalentsService.deleteById(appointmentEntity2.getId());
		}
		System.err.println(222222);
	}

}
